<?php

class mvc
{

    function __construct()
    {
        /**
         *  Requiring the configuration files
         */
        require(APP_PATH . 'config/config.php');
        require(APP_PATH . 'config/autoload.php');
        require(SYS_PATH . 'config/config.php');

        /**
         * Setting up the configuration settings 
         */
        Registry::$settings['autoload'] = $autoload;
        Registry::$settings['config'] = $config;
        Registry::$settings['system'] = $system;

        $this->loadLibraries();
    }

    function loadLibraries()
    {
        foreach (Registry::$settings['autoload'] as $key => $library) {
            if (file_exists(SYS_PATH . 'libraries/' . $library . '.php')) {
                /**
                 * create the new library
                 */
                Registry::$instance($library);
            } else {
                /**
                 * Return an error 
                 */
                echo '<br/><br/>The following library <strong>' . $library . '</strong> could not be found under<br /> ';
                echo '<strong>' . SYS_PATH . 'libraries/' . $library . '.php' . '</strong>';
            }
        }
    }

}

?>
